package com.ama.controller;

import com.ama.pojo.Person;
import com.ama.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@Controller
public class RegisterController {
    @Autowired
    PersonService personService ;
    @RequestMapping("/register")
    public String register(HttpServletRequest request, HttpServletResponse response) throws IOException {
        PrintWriter out = response.getWriter();
        Person new_person = new Person();
        new_person.setUsername(request.getParameter("username"));
        new_person.setPassword(request.getParameter("password"));
        new_person.setName(request.getParameter("name"));
        new_person.setSex(request.getParameter("sex"));
        new_person.setBirthday(request.getParameter("birthday"));
        new_person.setSchool(request.getParameter("school"));
        new_person.setPhone(request.getParameter("phone"));
        new_person.setEmail(request.getParameter("email"));
        new_person.setTrade(request.getParameter("trade"));
        new_person.setSalary(request.getParameter("salary"));
        new_person.setTip(request.getParameter("tip"));
        System.out.println(new_person);
        personService.register(new_person);
        out.println("alert('修改成功')");
        return "login";
    }
}
